package com.nifostasky.controller;

import com.nifostasky.config.StudentFeignClient;
import com.nifostasky.config.StudentFeignClientTwo;
import com.nifostasky.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/feign")
public class FeignController {
    @Autowired
    private StudentFeignClient studentFeignClient;

    @Autowired
    private StudentFeignClientTwo studentFeignClientTwo;


    /**
     * 通过feign客户端调用服务; fallback方式熔断
     */
    @GetMapping("/feignStudent/{id}")
    public Student feignStudent(@PathVariable("id") Integer id){
        return studentFeignClient.queryUserById(id);
    }

    /**
     * 通过feign客户端调用服务; fallbackFactory方式熔断
     */
    @GetMapping("/feignStudentTwo/{id}")
    public Student feignStudentTwo(@PathVariable("id") Integer id){
        return studentFeignClientTwo.queryUserById(id);
    }
}
